#include "BattleScene.h"
#include "Tables\TableManager.h"
#include "Tables\Tab_Actor.h"

using namespace cocos2d;
using namespace storm;

static const int cards[12][2] = { {100,50},{306,50},{512,50},{100,304},{306,304},{512,304},{100,608},{306,608},{512,608},{100,862},{306,862},{512,862} };

void BattleScene::onEnter()
{
	CCLayer::onEnter();
	Adapter::Instance()->AdjustLayer(this);
	CCSize designSize = Adapter::Instance()->DesignSize();
	CCSprite *pSprGB = CCSprite::create(CSTR(ResPathBattleUI + "btl_bg01.jpg"));
	pSprGB->setPosition(ccp(designSize.width*0.5f, designSize.height*0.5f));
	addChild(pSprGB);

	m_pCardLayer = CCLayer::create();
	m_pCardLayer->setPosition(ccp(designSize.width*0.5f, designSize.height*0.5f));
//	m_pCardLayer->setScale(0.8);
	addChild(m_pCardLayer);
	_creatArmyBox();

	m_pUIRoot = UIWindow::create();
	addChild(m_pUIRoot);
}

void BattleScene::_creatArmyBox()
{
	const unsigned int nArmySize = 12;

	for ( int i = 0; i < nArmySize; ++i )
	{
		
		CCNode* pArmyBox = CCNode::create();
		pArmyBox->setAnchorPoint(ccp(0.5,0.5));
		pArmyBox->setPosition(ccp(cards[i][0],cards[i][1]));
//		m_pCardLayer->addChild(pArmyBox);
		addChild(pArmyBox);
		Tab_Actor* pActor = TableManager::GetActorByID(i);
		std::string strIcon = pActor->GetBaseCardIcon();
		CCSprite* pCards = CCSprite::create(CSTR(ResPathCards + strIcon.c_str()+".png"));
		pCards->setAnchorPoint(ccp(0,0));
		pCards->setPosition(ccp(0,0));
		pArmyBox->addChild(pCards);
	}
	

}

